<template>
  <div>
    <div class="detail-page">
      <div class="header-area">
        <div class="title">{{ detail.title }}</div>
        <div class="article-info">
          <div class="other-info">
            <div class="time">
              <span>{{
                detail.createdTime | format("YYYY-MM-DD HH:mm:ss")
              }}</span>
            </div>
          </div>
        </div>
      </div>
      <editor-detail :content="detail.textContent" />
    </div>
  </div>
</template>
<script>
import EditorDetail from '@/components/editor-detail/index.vue'
import { getAnnounceDetail } from '@/api/operate'
export default {
  name: 'ArticleDetail',
  components: { EditorDetail },
  data: () => {
    return {
      detail: {}
    }
  },
  mounted() {
    this.getDetail()
  },
  created() {},
  methods: {
    async getDetail() {
      try {
        const res = await getAnnounceDetail({
          id: this.$route.params.id
        })
        if (res) {
          this.detail = res
        }
      } catch (err) {
        console.log('接口出错')
      }
    }
  }
}
</script>
<style scoped>
/* 全部评论列表 */
.all-comment-area {
  margin-top: 48px;
  position: relative;
}
.all-comment-area .header-area {
  display: table;
  margin-bottom: 16px;
}
.all-comment-area .header-area .title {
  border-left: 4px solid var(--primaryColor);
  font-size: 18px;
  height: 20px;
  line-height: 20px;
  font-weight: 500;
  padding: 0 12px;
  display: table-cell;
  vertical-align: middle;
}
.all-comment-area .header-area .title span {
  font-size: 14px;
  margin-left: 6px;
}

.all-comment-area .header-area .only-look-author {
  display: table-cell;
  vertical-align: middle;
  font-size: 12px;
  color: #969696;
  padding: 2px 8px;
  border: 1px solid #eee;
  border-radius: 16px;
  cursor: pointer;
}
.all-comment-area .header-area .only-look-author.active {
  color: #fff;
  background: var(--primaryColor);
  border: 1px solid var(--primaryColor);
}
.all-comment-area .order-btn-area {
  position: absolute;
  width: 300px;
  text-align: right;
  top: 2px;
  right: 0;
  font-size: 14px;
  cursor: pointer;
}
.all-comment-area .order-btn-area span {
  color: #969696;
  margin-left: 12px;
}
.all-comment-area .order-btn-area span.active {
  color: #2d2d2d;
}

.comment-list .comment-item {
  display: table;
  margin-top: 16px;
  width: 100%;
}
.comment-list .comment-item .user-avatar {
  display: table-cell;
  width: 40px;
  height: 40px;
  vertical-align: top;
  padding-right: 10px;
}
.comment-list .comment-item .user-avatar img {
  width: 40px;
  height: 40px;
  border-radius: 20px;
}

.comment-list .comment-item .comment-content {
  display: table-cell;
  border-bottom: 1px solid #eee;
  padding-bottom: 16px;
}
.comment-list .user-info .user-name {
  font-size: 15px;
  font-weight: 500;
}
.comment-list .user-info .reply-info {
  margin-top: 2px;
  font-size: 12px;
  color: #969696;
}
.comment-list .comment-context {
  margin: 10px 0 12px;
  font-size: 16px;
  line-height: 1.5;
  word-break: break-all;
}
.child-reply {
  display: table;
  width: 100%;
}
.child-reply-border {
  border-bottom: 1px solid #eee;
  margin-left: 50px;
  padding-bottom: 16px;
  margin-top: 16px;
}
.child-reply .user-avatar {
  display: table-cell;
  width: 40px;
  height: 40px;
  vertical-align: top;
  padding-right: 10px;
}
.child-reply .user-avatar img {
  width: 40px;
  height: 40px;
  border-radius: 20px;
}
.child-reply .user-info {
  display: table-cell;
}
.add-new-bar {
  padding: 16px 0 0 50px;
}
.to-user-name {
  color: #0681d0;
  margin-right: 10px;
}
.pager {
  margin: 30px auto 0;
  text-align: right;
}

.detail-page {
  background: #fff;
  padding: 32px;
  border-radius: 4px;
}
.header-area .title {
  font-size: 30px;
  font-weight: 700;
  word-break: break-word;
  margin-bottom: 0.5em;
}
.header-area .article-info {
  display: table;
  vertical-align: middle;
  margin-bottom: 32px;
}
.header-area .article-info .img-area {
  display: table-cell;
  width: 50px;
  height: 50px;
  vertical-align: middle;
}
.header-area .article-info .img-area img {
  width: 50px;
  height: 50px;
  border-radius: 25px;
}
.header-area .article-info .other-info {
  display: table-cell;
  margin-right: 8px;
  vertical-align: middle;
}
.header-area .article-info .other-info .author-name {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 6px;
}
.header-area .article-info .other-info .time {
  color: #969696;
  font-size: 13px;
}
.time > span {
  margin-right: 10px;
}
.like-area {
  display: table;
  vertical-align: middle;
}
.like-area .like-btn {
  display: table-cell;
  border: 1px solid #eee;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  text-align: center;
  vertical-align: middle;
  color: #969696;
}
.like-area .like-btn.active {
  color: var(--primaryColor);
}
.like-area .like-btn .iconfont {
  font-size: 20px;
  line-height: 40px;
}
.like-area .like-detail {
  display: table-cell;
  padding-left: 15px;
  vertical-align: middle;
}
/* 评论区域 */
.comment-area {
  background: #fff;
  margin-top: 10px;
  padding: 32px;
  margin-bottom: 24px;
  border-radius: 4px;
}
.do-comment-area {
  display: table;
}
.do-comment-area .avatar-area {
  width: 40px;
  height: 40px;
  vertical-align: top;
  display: table-cell;
}
.do-comment-area .avatar-area img {
  width: 40px;
  height: 40px;
  border-radius: 20px;
}
.do-comment-area .comment-input {
  display: table-cell;
  width: 100%;
  padding-left: 10px;
}
.do-comment-area .comment-input ::v-deep textarea {
  border: 1px solid #eee;
  border-radius: 4px;
  background-color: #fafafa;
}
.input-operate {
  margin-top: 16px;
  overflow: auto;
}
.input-operate .btn {
  float: right;
  color: #999;
  border: 1px solid #999;
  border-radius: 50px;
  padding: 4px 12px;
  margin-left: 8px;
  font-size: 14px;
  cursor: pointer;
}
.input-operate .btn.primary {
  color: #fff;
  border: 1px solid var(--primaryColor);
  background: var(--primaryColor);
}
.slide-fade-enter-active {
  transition: all 0.3s ease;
}
.slide-fade-leave-active {
  transition: all 0.3s cubic-bezier(1, 0.5, 0.8, 1);
}
.slide-fade-enter,
.slide-fade-leave-to {
  transform: translateY(-10px);
  opacity: 0;
}
</style>
